/*
 * SimAgent.h
 */

#ifndef SIMAGENT_H_
#define SIMAGENT_H_

#include <time.h>

#include "simworld.h"
#include "ril_debug.h"
#include "ctdlearner.h"
#include "cpolicies.h"
#include "cagent.h"
#include "cagentlogger.h"
#include "crewardmodel.h"
#include "canalyzer.h"
#include "cgridworldmodel.h"
#include "cvfunctionlearner.h"
#include <clinearfafeaturecalculator.h>
#include "SimEnvironment.h"
#include "SimRewardFunction.h"
#include "SimAction.h"
#include <string>
#include "Constants.h"

#include <ctorchvfunction.h>
#include <MLP.h>

class SimAgent{



	int exptNum;
	//char * load_q_filename;


	Simworld *myworld;

	CFeatureQFunction * qFeatureFunction;

	CQFunction *qFunction;

	CAgentController * qLearnerPolicy;
	CTDLearner * qFunctionLearner;
	CAgentLogger * logger;
	CAgent * agent;
	CEnvironmentModel * environmentModel;
	SimEnvironment * simEnv;
	SimRewardFunction *rewardFunction;
	CRewardLogger *rewardLogger;
	// parameters:
	double epsilon;
	int episodes;

	void addActions(double **a, int numActionTypes, int actionVectorSize);
	void action_add(std::vector<std::vector<double> > acts);

	void applyFnApprox(int numdimensions,
			unsigned int *tile_dimensions,
			unsigned int *tile_partitions,
			unsigned int *rbf_dimensions,
			unsigned int *rbf_partitions,
			double *offsets,
			double *sigma,
			int num_hidden,
			int numActionTypes
			);

public:

	string loadQFileName;

	int learner;
	int id;
	int functionApproxType;

	SimAgent(string load_q_filename, int pexptNum, SimEnvironment *pSimEnv);
	void setParams(double epsilon, int episodes);
	void init();
	void startLearning();

	CAgent * getAgent(){ return agent;}

	~SimAgent();
};

#endif /* SIMAGENT_H_ */
